<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="vue.js"></script>
<script src="vue-router.js"></script>
<body>
    <div id="app">
        <router-link to="/home">Home</router-link>
        <router-view></router-view>
        
    </div>

    <!-- home组件的模板 -->
    <template id="home">
        <div>
            <h1>这是HOME组件</h1>
            <router-link to="/home/login">登录</router-link> 
             <!-- 子路由要么写完整，要么什么都不写 -->
            <router-link to="/home/reg">注册</router-link>
            <router-view></router-view>
        </div>
    </template>

    <script>
        var home ={
            template:'#home'
        };
        var login = {
            template:'<h2 style="">这是登录组件</h2>'
        };
        var reg = {
            template:'<h3>这个是注册组件</h3>'
        };

       const router = new VueRouter({
            routes:[
            {
                path:'/home',
                component:home,
                children:[
                  {path:'/home/login',component:login},
                  {path:'/home/reg',component:reg},
                ]

            },

            ]
        })

        var vm = new Vue({
            el:'#app',
            router:router
        })
    </script>
</body>
</html>